package com.sl.biz.modular.process.controller;

import cn.hutool.core.lang.tree.Tree;
import com.sl.biz.modular.process.controller.request.ProcessCompGetByIdRequest;
import com.sl.biz.modular.process.dao.domain.dto.ProcessCompDTO;
import com.sl.biz.modular.process.dao.domain.entity.ProcessCompDO;
import com.sl.biz.modular.process.service.ProcessCompBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/process/comp")
@RequiredArgsConstructor
public class ProcessCompController {

    private final ProcessCompBizService processCompBizService;


    @PostMapping("/group_tree")
    public List<Tree<String>> groupTree() {
        return processCompBizService.groupTree();
    }


    @PostMapping("/list")
    public List<ProcessCompDTO> list(@RequestBody ProcessCompDO processComp) {
        return processCompBizService.list(processComp);
    }

    @PostMapping("/remove_by_id")
    public Boolean removeById(@RequestBody ProcessCompDO processComp) {
        return processCompBizService.removeById(processComp);
    }

    @PostMapping("/save")
    public Boolean save(@RequestBody ProcessCompDO processComp) {
        return processCompBizService.save(processComp);
    }

    @PostMapping("/get_by_id")
    public ProcessCompDTO getById(@RequestBody @Validated ProcessCompGetByIdRequest addRequest) {
        return processCompBizService.getById(addRequest);
    }


}
